package com.zqh.myfmmall.fallback;

import com.zqh.myfmmall.clients.ProductQueryClient;
import com.zqh.myfmmall.result.Result;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * @Description :
 * @Author :kono淇杭哒、
 * @Create 2022-03-16 20:28
 */
@Slf4j
public class ProductQueryClientFallback implements FallbackFactory<ProductQueryClient>{
    @Override
    public ProductQueryClient create(Throwable cause) {
        log.warn("调用商品查询服务出现异常："+cause);
        return new ProductQueryClient(){
            @Override
            public Result getByIds(List<String> ids) {
                return Result.internalServerError();
            }

            @Override
            public Result getById(String id) {
                return Result.internalServerError();

            }

            @Override
            public Result rootCategoryHighestSelling(String rootCategoryId) {
                return Result.internalServerError();

            }

            @Override
            public Result retrieveHighestSellingVo(String categoryId) {
                return Result.internalServerError();

            }

            @Override
            public Result retrieveLatest(String categoryId) {
                return Result.internalServerError();

            }
        };
    }
}
